package com.lp.yuojbackendjudgeservice.judge;


import com.lp.yuojbackendjudgeservice.judge.strategy.DefaultJudgeStrategyImpl;
import com.lp.yuojbackendjudgeservice.judge.strategy.JavaJudgeStrategyImpl;
import com.lp.yuojbackendjudgeservice.judge.strategy.JudgeContext;
import com.lp.yuojbackendjudgeservice.judge.strategy.JudgeStrategy;
import com.lp.yuojbackendmodel.codesrandbox.JudgeInfo;
import com.lp.yuojbackendmodel.entity.QuestionSubmit;

/**
 * 判题管理 (更加情况选择合适的判题逻辑)
 */
public class JudgeManager {
    JudgeInfo doJudge(JudgeContext judgeContext) {
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategyImpl();
        if (language.equals("java")) {
            judgeStrategy = new JavaJudgeStrategyImpl();
        }
        return judgeStrategy.doJudge(judgeContext);
    }
}
